package com.swg.wxorder.service.impl;

import com.swg.wxorder.dao.CategoryRepository;
import com.swg.wxorder.entity.ProductCategory;
import com.swg.wxorder.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 【swg】.
 * @Date 2018/6/23 11:13
 * @DESC
 * @CONTACT 317758022@qq.com
 */
@Service
@Slf4j
public class CategoryServiceImpl implements CategoryService{
    @Autowired
    private CategoryRepository categoryRepository;

    @Override
    public ProductCategory getByCategoryId(Integer categoryId) {
        return categoryRepository.findOne(categoryId);
    }

    @Override
    public List<ProductCategory> productCategoryListByType(List<Integer> categoryTypeList) {
        return categoryRepository.findByCategoryTypeIn(categoryTypeList);
    }

    @Override
    public ProductCategory save(ProductCategory productCategory) {
        return categoryRepository.save(productCategory);
    }

    @Override
    public List<ProductCategory> getAll() {
        return categoryRepository.findAll();
    }
}
